<template>
  <div class="app-container">
    <!-- 添加或修改OA 请假申请对话框 -->
    <el-dialog :title="title" v-model="open" append-to-body width="80%">
      <el-form ref="formRef" :model="form" label-width="110px" :disabled="disabled">
        <el-form-item label="申请人" prop="creatorName">
          <el-input v-model="form.creatorName" maxlength="10" show-word-limit />
        </el-form-item>
        <el-form-item label="政策标题" prop="title">
          <el-input v-model="form.title" type="textarea" maxlength="200" show-word-limit />
        </el-form-item>
        <el-form-item label="政策内容" prop="content">
          <el-input v-model="form.content" type="textarea" maxlength="12000" show-word-limit
            :autosize="{ minRows: 6, maxRows: 10 }" style="width: 100%;" />
        </el-form-item>
        <el-form-item label="政策类型" prop="policyType">
          <el-select v-model="form.policyType">
            <el-option v-for="item in sys_policy_type" :key="item.value" :label="item.label"
              :value="item.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="失效时间" prop="expirationTime">
          <el-date-picker clearable size="default" v-model="form.expirationTime" type="date" value-format="YYYY-MM-DD"
            style="width: 100%;" popper-class="large-date-picker" />
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script setup>
  import {
    ref,
    reactive,
    onMounted
  } from 'vue';
  import {
    ElMessage,
    ElMessageBox
  } from 'element-plus';
  import {
    getLeave,
    handle,
    rejectLast,
    taskBack
  } from "@/api/system/leave";
  import {
    anyNodeList
  } from "@/api/flow/execute";
  import {
    useDict
  } from '@/utils/dict';
  // 获取政策类型字典（返回响应式对象）
  const {
    sys_policy_type
  } = useDict('sys_policy_type');
  // 定义 props
  const props = defineProps({
    value: {
      type: String,
      default: "",
    },
    creatorName: {
      type: String,
      default: ""
    },
    businessId: {
      type: String,
      default: "",
    },
    nodeCode: {
      type: String,
      default: ""
    },
    taskId: {
      type: String,
      default: "",
    },
    disabled: {
      type: Boolean,
      default: false,
    },
    showAnyNode: {
      type: Boolean,
      default: false,
    },
    infoVo: {
      type: Object,
      default: () => ({}),
    },
  });

  // 定义 emits
  const emit = defineEmits(['refresh']);

  // 响应式变量
  const open = ref(false);
  const formRef = ref(null);
  const form = ref({
    message: ''
  })
  const title = ref("查看");
  const disabled = ref(true)
  // 初始化
  onMounted(() => {
    getLeave(props.businessId).then((res) => {
      form.value = res.data
    })
    open.value = true;
  });
</script>